<template>
	<!-- <view class=""> -->
	<view class="chatInterface container">
		<view class=""
			style="position:fixed;top:0;height:120rpx; font-size:14px; padding:12rpx 20rpx; background-color: #F5F5F5;z-index: 9999;border-bottom:1px solid #FFFFFF;">
			<text>当您在本平台购买药品时，定点医药机构的药师会根据您的病症为您提供用药咨询服务。问询内容仅供建议使用，不作处方判断，请根据自身情况或医嘱理性购买。</text>
		</view>

		<view>
			<view class="scroll" :style="{height: scrollHeight}">
				<scroll-view style="height:90%" :scroll-into-view="scrollViewId" scroll-y  
				:scroll-with-animation="true"
					:refresher-enabled='true' refresher-threshold='100' :refresher-triggered="isTrigger" @refresherpulling="onPulling" @refresherrefresh="refreshPulldown" 	@refresherrestore="onRestore"
					@refresherabort="onAbort">
			<!-- <scroll-view id='scroll-view' class="scroll-view" scroll-y="true" :scroll-with-animation="true"
				:refresher-enabled='true' refresher-threshold='100' :refresher-triggered="isTrigger"
				@refresherpulling="onPulling" @refresherrefresh="refreshPulldown" @refresherrestore="onRestore"
				@refresherabort="onAbort" :style="{height: style.contentViewHeight + 'px'} " :scroll-top='scrollTop'> -->

				<view class="all-history-loaded">
					{{ allHistoryLoaded ? '已经没有更多的历史消息' : '下拉获取历史消息' }}
				</view>
				<view class="msg-wrap" @touchstart="touchstart">
					<!-- <view class="all-history-loaded">
						<uni-load-more :status="statusLoad" :content-text="contentText" v-if="showLoadMore" />
					</view> -->
					<view>
						<view class="msg-item" v-for="(msg, index) in msgs" :key="index">
							<view class="" v-if="msg.sendType !== 6">
								<text class="time-wrap">{{ msg.sendTime }}</text>
								<!-- 医生 -->
								<view class="msg-con-wrap msg-left"
									v-if="msg.fromUser==doctorId && msg.fromUser!=patientId">
									<!-- 此处头像 -->
									<!-- 医生头像 -->
									<image :src="doctorInfo.avatar || doctorInfo.doctorIcon" class="avatar-wrap" />
									<!-- 服务人员头像 -->
									<!-- <image :src='doctorInfo.storeLogo' class="avatar-wrap"></image> -->

									<!-- 现场开方消息 -->
									<view class="chufangMsg" v-show="msg.sendType == 1 || msg.sendType==8">
										<view class="patientInfo"
											style="border-radius: 12rpx; background-color: #FFFFFF;">
											<!-- 查看电子处方 -->
											<!-- @click="toSeePrescription(`/pages/my/electronic?prescriptionId=${msg.chatContent.id}`)" -->

											<view mode="title" style="padding: 0 10rpx;">
												<view class=""
													style="text-align: center; padding: 10rpx; line-height: 40rpx; height: 40rpx;border-bottom: 1px solid #dcdcdc;">
													<text class="chufang">{{doctorInfo.doctorName}}已开具处方</text>
												</view>
												<view class="patientInfo">
													<uni-row class="demo-uni-row " style="display: block;">
														<uni-col :span="9"><text>患者信息：</text></uni-col>
														<text class="gray_font"
															style=" word-break: break-all; margin-left: -10px;">
															{{ msg.chatContent.name }}
														</text>
													</uni-row>
													<uni-row class="demo-uni-row " style="display: block;">
														<uni-col :span="9"><text>医嘱：</text></uni-col>
														<text class="gray_font"
															style=" word-break: break-all;margin-left: -10px;">
															{{ msg.chatContent.entrust }}
														</text>
													</uni-row>
													<uni-row class="demo-uni-row " style="display: block;">
														<uni-col :span="9"><text>诊断：</text></uni-col>
														<text class="gray_font"
															style=" word-break: break-all;margin-left: -10px;">
															{{ msg.chatContent.diagnosis }}
														</text>
													</uni-row>
													<view class="">
														<!-- 审核状态 -->
														<span
															:style="msg.chatContent.status==0 ? sccessStatus : rejectStatus">{{prescriptionStatus[msg.chatContent.status]}}</span>

													</view>
													<view class="demo-uni-row drugNameRow"
														style="background-color: #F5F9FA;font-size: 28rpx;"
														v-if="msg.chatContent.prescribeDrugChatDTOS">
														<view :span="22" v-for="(item,i) in (msg.chatContent.prescribeDrugChatDTOS)" :key="i">
															{{item.drugName || ''}}({{item.manufacturerName || ''}}){{item.drugCount || ''}}
														</view>
													</view>
												</view>
											</view>
										</view>
										<!-- 点击出示二维码 -->
										<!-- <view v-if="(chushiOrshouqi==true)&&(activeId==index)"> -->
										<view class="EWM patientInfo"
											style=" border-radius: 12rpx;background-color: #FFFFFF;">
											<text style="display:block; text-align : center; color: #50C9BD;"
												type="default" :key="msg.chatContent.id"
												@click="gotoBuyDrug(msg.chatContent.id,msg.chatContent.orderType)">去购药</text>
										</view>
									</view>
									<!-- 图片 -->
									<view class="msg msgImage" v-if="msg.sendType == 3">
										<image class="imageMsg" mode='aspectFit'
											:src="msg.chatContent || '../../pagesSub/static/images/bank_card.png'"
											:data-url="msg.chatContent" @click="showImageFullScreen"></image>
									</view>
									<!-- 语音 -->
									<GoEasyAudioPlayer v-if="msg.sendType == 4" style="margin-left: 20rpx;"
										:src="msg.chatContent.audioUrl" :duration="msg.chatContent.audioTime" />

									<!-- 普通消息 -->
									<view class="msg left-txt-msg" v-show="msg.sendType == 5">{{ msg.chatContent }}
									</view>
									<!-- 问诊小结 -->
									<view class="msg patientInfo" style="line-height: 52rpx;"
										v-show="msg.sendType == 9">
										<h3 style='font-weight: 900;'>问诊小结：</h3>
										{{ msg.chatContent }}
									</view>
								</view>

								<!-- 患者 -->
								<view class="msg-con-wrap msg-right"
									v-if="msg.fromUser==patientId&& msg.fromUser!=doctorId">
									<!-- 图文问诊消息 -->
									<view class="msg patientInfo" v-if="msg.sendType == 2" :id="msg.chatContent.id"
											@click="toSeePicDetail(msg.chatContent.id,msg.chatContent.orderId)">
											<view mode="title">
												<view
													style="text-align: center; padding: 10rpx; line-height: 40rpx; height: 40rpx;border-bottom: 1px solid #dcdcdc;">
													<text>{{ msg.chatContent.orderType == 1? '图文问诊' :'免费咨询'}}</text>
												</view>
												<view class="patientInfo">
													<uni-row class="demo-uni-row" style="display: block;">
														<uni-col :span="9"><text>确诊疾病：</text></uni-col>
														<text class="gray_font"
															style=" word-break: break-all;margin-left: -10px;">
															{{msg.chatContent.confirmedDisease }}
														</text>
													</uni-row>
													<uni-row class="demo-uni-row" style="display: block;">
														<uni-col :span="9"><text>病情描述：</text></uni-col>
														<text class="gray_font"
															style=" word-break: break-all;margin-left: -10px;">
															{{ msg.chatContent.illnessConetxt }}
														</text>
													</uni-row>
													<uni-row class="demo-uni-row">
														<uni-col :span="9"><text>病情图片：</text></uni-col>
														<uni-col :span="14" class="image-box">
															<span v-for="(item, i) in (msg.chatContent.image)" :key="i">
																<image class="image" mode='aspectFit' :src="item"
																	:data-url="item"
																	@click.stop="showImageFullScreen" />
															</span>
														</uni-col>
													</uni-row>
												</view>
												<view class="footer-box" v-if='msg.chatContent.status==1'>
													<button type="primary" class="chatBtn"
														@click.stop="openRefusal(msg.chatContent.id)"> 退诊
													</button>
												</view>
												<view class="picWordTips" v-show='msg.chatContent.status !=1'>
													{{picWordStatus[msg.chatContent.status]}}
												</view>
											</view>
										</view>
									<!-- 图片 -->
									<view class="msg msgImage" v-show="msg.sendType == 3">
										<image class="imageMsg" mode='aspectFit'
											:src="msg.chatContent || '../../pagesSub/static/images/bank_card.png'"
											:data-url="msg.chatContent" @click="showImageFullScreen"></image>
									</view>
									<!-- 语音 -->
									<GoEasyAudioPlayerFromDoctor v-show="msg.sendType == 4" style="margin-right: 20rpx;"
										:src="msg.chatContent.audioUrl" :duration="msg.chatContent.audioTime" />
									<!-- 用药咨询 -->
									<view class="msg patientInfo" v-show="msg.sendType == 7"
											:id="msg.chatContent.id">
											<view class=""
												style="text-align: center; padding: 10rpx; line-height: 40rpx; height: 40rpx;border-bottom: 1px solid #dcdcdc;">
												<text>{{ msg.chatContent.title? msg.chatContent.title.slice(2) : '' }}</text>
											</view>
											<button class="toSeeBtn" size="mini"
												@click="toSeeMedApply(msg.chatContent)">
												去查看
											</button>
										</view>
									<!-- 普通消息 -->
									<view class="msg right-txt-msg" v-show="msg.sendType == 5">{{ msg.chatContent }}
									</view>
									<!-- 患者头像 -->
									<image :src="patientInfo.avatar" class="avatar-wrap" />
								</view>

							</view>

							<!-- 提醒消息 -->
							<!-- 1.问诊开始
								2.问诊结束
								3.拒诊
								4.退诊
								5.开具处方待付款
								6.开具处方已付款
								7.用药申请通过
								8.用药申请拒绝 -->
							<view style="text-align: center; font-size: 12px;" v-show="msg.sendType == 6">
								<text class="gray_font">——{{ msg.chatContent }}——</text>
								<!-- <view class="gray_font" style="font-size: 14px; margin-top: 3px;"
									v-if='msg.type == 1 && msg.chatContent.orderType ==1'>
									<p>1.问诊期间，医患对话不限次数</p>
									<p>2.医生给出明确建议后，问诊结束</p>
									<p>3.问诊最长48小时，到期将自动结束</p>
								</view> -->
							</view>
						</view>
						<view id="bottom"></view>
					</view>
				</view>

			</scroll-view>
		</view>
		<!-- 底部操作栏 -->
		<view class="action-box" v-if='isActivation!=1'>
				<!-- 医生的角色 -->
				<view class="num-text-wrap" v-if="hideHasNum">
					<text>当前咨询还剩
						<text style="color: #7ED2C3; font-weight: 500;">{{hasNum}}</text>个回合</text>
				</view>
			
			<!-- <view class="num-text-wrap" v-if="hasEndTime">
				<text>本次咨询将在
					<text style="color: #7ED2C3;">{{endTime}}</text>自动关闭</text>
			</view> -->
			<view class="action-top">
				<view :class="[!isVoice ? 'record-icon record-open' : 'record-icon']" @click="clickVoice"></view>
				<button class="record-input" :disabled="isDisabledButton" v-if="!isVoice" @touchstart="startVoice"
					@touchend="endVoice" @touchcancel="cancelVoice">
					{{ recording ? '松开发送' : '按住录音' }}
				</button>
				<view class="message-input uni-textarea" v-else>
					<!-- GoEasyIM最大支持3k的文本消息，如需发送长文本，需调整输入框maxlength值 -->
					<textarea :adjust-position="true" :show-confirm-bar="false" cursor-spacing='20' :auto-height="true"
						maxlength="200" v-model="msgText" @click="clickInput" />
				</view>

				<view class="file-icon image-icon" @click="gotoCamera"></view>
				<span class="send-message-btn" @click="sendTextMessage">发送</span>
			</view>

		</view>
		<!-- 录音中gif -->
		<view class="record-loading" v-if="recording"></view>

		<!-- 用药申请弹窗 -->
		<uni-popup ref="medApplyPopup" type="center">
				<view class="dialogContent">
					<view class="icon_close">
						<image @click="closeCf" style="width: 40rpx;height: 40rpx;float: right;"
							src="../../pagesSub/static/images/icon_close_gray.png"></image>
						<h4 style='text-align: center;'>用药申请</h4>
					</view>
					<view class="content" style="margin-top: 30rpx;">
						<view>
							<text class>姓名： {{ prescriptionInfo.name }}</text>
							<text>年龄： {{ prescriptionInfo.age }}</text>
							<text>性别： {{ prescriptionInfo.sex == 1 ? '男' : prescriptionInfo.sex == 2 ? '女' : ''}}</text>
						</view>
					</view>
					<view>
						<view style="display: flex;justify-content: space-between;">
							RP
							<text class="float:right" :style="chatContent.status==2 ? (sccessStatus) : rejectStatus"
								v-show='chatContent.status !=1'>
								{{medConsultStatus[chatContent.status]}}
							</text>
							<text class="float:right" :style="auditStatus" v-show='chatContent.status ==1'>
								{{medConsultStatus[chatContent.status]}}
							</text>
						</view>
						<scroll-view scroll-y="true" class="scroll-Y">
							<view class="RP_content" :key="index"
								v-for="(item,index) in prescriptionInfo.prescriptPatientJsonResponseBody.patientDrugInfoRequestBody">
								<view class="drugTit">
									<view><text>{{item.drugName}} </text></view>
									<view><text>x{{item.count}}</text></view>
								</view>
								<view style="margin-top: 10rpx;font-size: 12px;" class="medical_info_content gray_font">
									<view>规格：{{item.specification}}</view>
									<view>用药天数：{{item.defaultUsageDays}}天</view>
									<view>
										用法用量:{{item.drugFrequency}},每次{{item.drugOnceMetering}}{{item.useUnit}},{{item.medicationExplanation}}
									</view>
								</view>
							</view>
						</scroll-view>
					</view>
				</view>
			</uni-popup>
		<!-- 退诊弹窗 -->
		<uni-popup ref="refusalPopup" type="center">
				<view class="inputDialog">
					<view class="title">提示</view>
					<view style="padding: 20rpx 30rpx;text-align: center;">
						{{ refusalPatientContent }}
					</view>
					<view class="button-bottom">
						<view class="cancel" style="border-right: 1px solid #eeeeee;" @click="dialogClose">取消</view>
						<button  :disabled="disabledSave" @click="refusalConfirm" class="blue_words arc_button"
							style="background-color: #FFFFFF !important;width:53% ;">确认</button>
					</view>
				</view>
			</uni-popup>
	</view>
	</view>
</template>

<script>
	import {
		recordList,
		chatSend,
		//   consultationDetail,
		  patientDetail,
		//   Withdrawal,
		updateReadStatus,
		getSessionInfo,
		newChat,
	} from "@/api/service.js";
	import Cache from "@/utils/cache.js";
	import store from "@/store";
	import {
		TOKENNAME,
		HTTP_REQUEST_URL
	} from "@/config/app.js"; // UIDNAME
	import GoEasyAudioPlayer from "@/pagesSub/components/GoEasyAudioPlayer/GoEasyAudioPlayer";
	import GoEasyAudioPlayerFromDoctor from "@/pagesSub/components/GoEasyAudioPlayer/GoEasyAudioPlayerFromDoctor";
	const recorderManager = uni.getRecorderManager(); //录音API

	export default {
		components: {
			GoEasyAudioPlayer,
			GoEasyAudioPlayerFromDoctor,
		},
		data() {
			return {
				holdKeyboard: true, //保持键盘弹起
				isDisabledButton: false, //录音按钮
				disabledSave: false,
				_freshing: false,
				isTrigger: false, //是否开启下拉刷新
				getNewTimer: {},
				// scrollTop: 0,
				// old: {
				// 	scrollTop: 0,
				// },
				// descriptionId: 0,
				text: "",
				// size: 150,
				// colorDark: "#000000",
				// colorLight: "#ffffff",
				activeId: 0, //点击出示二维码下标
				chushiOrshouqi: false,
				// msgHeight:'600',
				auditStatus: "background-color: #0F95F5; color: #ffffff; font-size: 12px; padding: 0 3px; line-height:40rpx;", //待审核样式
				sccessStatus: "background-color: #D0F4ED; color: #81D7C5; font-size: 12px; padding: 0 3px; line-height:40rpx;", //审核通过样式
				rejectStatus: "background-color: #D57667; color: #FFFFFF; font-size: 12px; padding: 0 3px;line-height:40rpx;", //审核拒绝样式
				chatContent: {}, //用药咨询的内容
				consultType: 0, //接诊类型
				// hasTime: 0, //剩余时间 倒计时
				hasNum: 0, //剩余回合数
				hasEndTime: false, //是否展示结束时间
				endTime: "", //自动结束问诊时间
				picWordStatus: {
				  //图文咨询状态
				  1: "待接诊",
				  2: "问诊中",
				  3: "已拒单",
				  4: "已退诊",
				  5: "已结束",
				  6: "自动已退单",
				  // status进行判断1待接诊,2问诊中,3已拒单,4已退诊,5已结束,6自动已退单~~~~
				},
				prescriptionStatus: {
					0: "审核通过",
					1: "审核拒绝",
					2: "审核中",
				},
				medConsultStatus: {
				  //用药申请状态
				  1: "待审核",
				  2: "审核通过",
				  3: "审核拒绝",
				  4: "已取消",
				  5: "已结束",
				  6: "自动已退单",
				},
				// tuizhenDisabled: false, //退诊按钮是否置灰
				isActivation: 0, // 0 激活 ，1--未激活
				isSendDisabled: false, //底部输入框部分是否置灰
				WithdrawalId: 9, //退诊id
				doctorInfo: {}, // 医生及患者信息
				total: 0, //总条数
				nowCount: 0, //当前累计显示条数
				listData: [], //列表数据
				// 查询参数
				queryParams: {
					pageNum: 1, //第几页
					pageSize: 30, //每页显示条数
				},
				prescriptionId: 0, //用药申请id
				prescriptionInfo: {
					prescriptPatientJsonResponseBody: {},
				}, //用药申请信息
				conclusionTxt: "",
				sessionId: 0, //会话id 结束问诊时需要
				isActive: 0, //是否激活 0是 1否
				orderType: 1, //订单状态(1图文咨询,2用药咨询,3免费咨询,4现场开方)
				patientInfo: {},
				allHistoryLoaded: false, // 全部历史消息
				voicePath: "",
				isVoice: true, //录音按钮
				// recording: false, //语音录音中
				doctorId: 0, // 医生uid
				patientId: 0, //患者id
				showOptions: false,
				msgText: "", //输入框消息
				hideEnd: false, //是否展示结束问诊tag
				hasNum: 0,
				hideHasNum: false, //显示回合数
				msgType: "info",
				sendType: "",
				refusalPatientContent: "您确定取消已提交的图文咨询吗？",
				msgs: [
					// 	{
					// 	fromUser: 1, //发送人
					// 	toUser: 1, //接收人
					// 	id: 9, //聊天记录id
					// 	chatContent: '', //消息
					// 	sendType: 7, // 文本：text；图片：img；语音：audio；视频：video
					// 	// from: '', // 消息来源：自己：self；对方：other
					// 	sendTime: '', // 发送时间
					// 	isRead: 1, // 是否已读
					// 	avatar: '', //头像
					// 	// nickName: '', // 用户昵称
					// 	img: '', // 发送图片地址
					// 	audio: '' // 音频地址
					// },
				], // 消息列表，需要从后台取，
				image: "", //要发送的图片
				// audio: '',  //
				setInter: "", //计时器
				audioTime: 0, //语音时长
				showLoadMore: false,
				statusLoad: "more",
				contentText: {
					contentdown: "查看更多",
					contentrefresh: "加载中...",
					contentnomore: "没有更多",
				},
				// 聊天页面时时滚动样式
				style: {
					pageHeight: 0,
					contentViewHeight: 0,
					footViewHeight: 80,
					mitemHeight: 0,
				},

				recording: false, //标识是否正在录音
				isStopVoice: false, //加锁 防止点击过快引起的当录音正在准备(还没有开始录音)的时候,却调用了stop方法但并不能阻止录音的问题
				voiceInterval: null,
				voiceTime: 0, //总共录音时长
				canSend: true, //是否可以发送
				Recorder: uni.getRecorderManager(),
				Audio: uni.createInnerAudioContext(),
				platform: "", //客户端平台
				// storeType:'', //角色 1：医生 5：服务人员
				serviceInfo:{},//服务人员信息
				statusBarHeight: 0,		// 状态栏高度
				scrollViewId: '',		// 滚动到最底部
				scrollHeight: 'auto',		// 内容区域高度

			};
		},
		created() {
			const res = uni.getSystemInfoSync(); //获取手机可使用窗口高度     api为获取系统信息同步接口
			// console.log(res, '手机高度999')
			this.platform = res.platform; // 客户端平台 ios android mac等

			// console.log(res, '手机高度999')
			this.style.pageHeight = res.windowHeight;
			this.style.contentViewHeight =
				res.windowHeight - (res.screenWidth / 750) * 100 - 110; //像素   因为给出的是像素高度 然后我们用的是upx  所以换算一下
			if (res.platform == "ios" || this.platform == "devtools") {
				this.style.contentViewHeight =
					res.windowHeight - (res.screenWidth / 750) * 100 - 140; //像素   因为给出的是像素高度 然后我们用的是upx  所以换算一下
			}
			// console.log(this.style, this.style.contentViewHeight, '手机高度999999---')
		},
		async onShow() {
			// 初始化内容高度
			this.setScrollHeight()
			
			// 初始化状态栏高度
			uni.getSystemInfo({
				success: res=>{
					this.statusBarHeight = res.statusBarHeight
					console.log(res,'状态栏')
				}
			})
		

			this.isVoice = true;
			// 获取会话激活状态及剩余回合数
			// this.getChatInfo();

			// 跳转到其他页面后返回时 需在上次所在页数的聊天记录，  如果是发送消息后请求最新数据 pageNum=1
			this.queryParams.pageNum != 1 ?
				await this.getRecordList() :
				await this.getRecordList({
					pageNum: 1,
				});
			this.getNewReadMsg({
				pageNum: 1,
			});

			// 轮询请求聊天记录
			this.getNewTimer = setInterval(() => {
				// 加载聊天记录
				this.getNewReadMsg({
					pageNum: 1,
				});
			}, 5000);
			if (this.queryParams.pageNum == 1) {
				setTimeout(() => {
					this.initScrollBar();
					// this.scrollToBottom(); //创建后调用回到底部方法
				}, 500);
			}
		},

		onLoad(option) {
			
			if(option.item){
				// 列表或详情跳转到聊天
				this.doctorInfo = JSON.parse(decodeURIComponent(option.item));
				this.doctorId = this.doctorInfo.doctorId;
				this.patientId = this.doctorInfo.patientId;
			}
			// console.log(this.doctorInfo,'传进来的数据是就诊人信息999---')

			uni.setNavigationBarTitle({
				title: this.doctorInfo.doctorName,
			});
			this.doctorId = this.doctorInfo.doctorId || store.state.app.serviceUid; // 服务人员id
		
			this.patientInfo.avatar = store.state.app.userPhoto;
			this.showLoadMore = false;
			recorderManager.onStop(function(res) {
				this.voicePath = res.tempFilePath;
			});
			setTimeout(() => {
				this.scrollToBottom(); //创建后调用回到底部方法
			}, 500);
			//录音开始事件
			this.Recorder.onStart((e) => {
				this.beginVoice();
			});
			//录音结束事件
			this.Recorder.onStop((res) => {
				clearInterval(this.voiceInterval);
				this.handleRecorder(res);
			});
		},

		onHide() {
			if (this.getNewTimer) {
				clearInterval(this.getNewTimer);
				this.getNewTimer = null;
			}
			if (this.timer) {
				clearTimeout(this.timer);
				this.timer = null;
			}
			if (this.setInter) {
				clearInterval(this.setInter);
				this.setInter = null;
			}
		},
		destroyed() {
			if (this.getNewTimer) {
				clearInterval(this.getNewTimer);
				this.getNewTimer = null;
			}
			if (this.timer) {
				clearTimeout(this.timer);
				this.timer = null;
			}
		},
		methods: {

			
// 初始化滚动
		initScrollBar(){
			setTimeout(()=>{
				this.scrollViewId = ''
				setTimeout(()=>{
					this.scrollViewId = 'bottom'
					// setTimeout(()=>{this.scrollViewId = ''}, 100)
				}, 100)
			}, 100)
			
			console.log(this.scrollViewId,'滚动高度888999init')
		},

// 切换选择
		// togglePicker(height=0, type=''){
		// 	this.showEmoji = false
		// 	this.showFile = false
		// 	let status = height >0 ? true : false
			
		// 	// switch(type){
		// 	// 	case 'emoji':
		// 	// 		this.showEmoji = status; break
		// 	// 	case 'file':
		// 	// 		this.showFile = status; break
		// 	// }
			
		// 	setTimeout(()=>{
		// 		this.setScrollHeight(height)
		// 		this.initScrollBar()
		// 	}, 50)
		// },
			// 设置scroll的高度
		setScrollHeight(descHeight=0){
			// #ifdef MP-WEIXIN
			this.scrollHeight = `calc(100vh - 110rpx - ${descHeight}px)`
			// #endif
			// #ifdef APP-PLUS
			this.scrollHeight = `calc(100vh - 110upx - ${descHeight}px)`
			// #endif
			// #ifdef H5
			this.scrollHeight = `calc(100vh - 110upx - 88rpx - ${descHeight}px)`
			// #endif
			
			console.log(this.scrollHeight,'滚动高度000--')
		},
			// 自定义下拉刷新控件被下拉
			onPulling(e) {
				// console.log("onpulling", e);
				if (e.detail.deltaY < 0) return; // 防止上滑页面也触发下拉
				this.isTrigger = true;
			},
			// 自定义下拉刷新被复位
			onRestore() {
				this.isTrigger = "restore"; // 需要重置
				// console.error("onRestore");
			},
			// 自定义下拉刷新被中止
			onAbort() {
				// console.error("onAbort");
			},
			// 自定义下拉刷新被触发
			refreshPulldown() {
				// console.log(this._freshing, '下拉刷子999')
				if (this._freshing) return;
				this._freshing = true;
				if (this.nowCount > 0 && this.nowCount >= this.total) {
					this.statusLoad = "noMore";
					this.allHistoryLoaded = true;
					// this.showLoadMore = false;
					this.isTrigger = false;
					this._freshing = false;
					// uni.stopPullDownRefresh(); //停止当前页面下拉刷新
				} else {
					let _this = this;
					// 获取聊天记录
					this.getRecordList();
					this.showLoadMore = false;
					this.allHistoryLoaded = false;
					this._freshing = false;
					this.isTrigger = false;
					// uni.stopPullDownRefresh(); //停止当前页面下拉刷新
					_this.statusLoad = "loading";
				}
			},
			//用户触摸屏幕的时候隐藏键盘
			touchstart() {
				uni.hideKeyboard();
			},

			//准备开始录音
			startVoice(e) {
				if (this.hideHasNum) {
					//orderType==1 时属于图文问诊  this.hasEndTime==true 显示倒计时 ,
					if (this.hasNum < 1) {
						this.isDisabledButton = true;
						uni.showToast({
							title: "回合数耗尽，无法发送消息",
							icon: "none",
							duration: 3000,
						});
						this.Recorder.stop();
						return;
					}
				}
				if (!this.Audio.paused) {
					//如果音频正在播放 先暂停。
					this.stopAudio(this.AudioExam);
				}
				let _this = this;
				_this.recording = true;
				_this.isStopVoice = false;
				_this.canSend = true;
				_this.PointY = e.touches[0].clientY;
				_this.Recorder.start({
					format: "mp3",
				});
			},
			//录音已经开始
			beginVoice() {
				let _this = this;
				if (_this.isStopVoice) {
					_this.Recorder.stop();
					return;
				}
				// this.voiceTitle = '松开 结束'
				_this.voiceInterval = setInterval(() => {
					_this.voiceTime++;
				}, 1000);
			},
			//结束录音
			endVoice() {
				let _this = this;
				_this.isStopVoice = true; //加锁 确保已经结束录音并不会录制
				_this.Recorder.stop();
				_this.recording = false;
				// this.voiceTitle = '按住 说话'
			},
			//录音被打断
			cancelVoice(e) {
				let _this = this;
				_this.voiceTime = 0;
				// this.voiceTitle = '按住 说话';
				_this.canSend = false;
				_this.Recorder.stop();
			},
			//处理录音文件
			handleRecorder({
				tempFilePath,
				duration
			}) {
				let contentDuration;
				let _this = this;
				console.log("松手99999---");
				// #ifdef MP-WEIXIN
				_this.voiceTime = 0;
				if (duration < 600) {
					// this.voiceIconText = "说话时间过短";
					uni.showToast({
						title: "说话时间过短",
						icon: "none",
						duration: 3000,
					});
					setTimeout(() => {
						_this.recording = false;
					}, 200);
					return;
				}
				contentDuration = duration / 1000;
				// #endif

				// #ifdef APP-PLUS
				contentDuration = _this.voiceTime + 1;
				_this.voiceTime = 0;
				if (contentDuration <= 0) {
					_this.voiceIconText = "说话时间过短";
					setTimeout(() => {
						_this.recording = false;
					}, 200);
					uni.showToast({
						title: "说话时间过短",
						icon: "none",
						duration: 3000,
					});
					return;
				}
				// #endif
				_this.recording = false;

				_this.canSend && _this.videoUpload(tempFilePath, contentDuration);
			},
			//控制播放还是暂停音频文件
			handleAudio(item) {
				this.AudioExam = item;
				this.Audio.paused ? this.playAudio(item) : this.stopAudio(item);
			},
			//播放音频
			playAudio(item) {
				this.Audio.src = item.content;
				this.Audio.hasBeenSentId = item.hasBeenSentId;
				this.Audio.play();
				item.anmitionPlay = true;
			},
			//停止音频
			stopAudio(item) {
				item.anmitionPlay = false;
				this.Audio.src = "";
				this.Audio.stop();
			},

			scroll: function(e) {
				// this.old.scrollTop = e.detail.scrollTop;
			},
			// 查询新的聊天记录
			getNewReadMsg() {
				let _this = this;
				let newData = [];
				newChat(_this.doctorId, _this.patientId)
					.then((res) => {
							this.getChatInfo(); //激活状态
						// uni.hideLoading();
						newData = res.data || [];
						newData &&
							newData.map((item) => {
								if (typeof item.chatContent != "object") {
									if (
										item.sendType == 1 ||
										item.sendType == 8 ||
										item.sendType == 2 ||
										item.sendType == 4 ||
										item.sendType == 7
									) {
										// 1--,现场开方消息 2.图文咨询消息 3 图片 4. 语音 5. 普通消息 6 提醒消息 7. 用药咨询 8 开具处方 9. 问诊小结
										if (item.chatContent) {
											item.chatContent = JSON.parse(item.chatContent);
										}
										return item;
									}
									return item;
								}
							});
						this.msgs.push(...newData.reverse());
						this.msgs = this.ArrSet(this.msgs, "id");
						// console.log(this.msgs, '所有消息999---')
						// 根据消息id去重
						// var obj = {};
						// this.msgs = this.msgs.reduce(function(item, next) {
						// 	obj[next.id] ? '' : obj[next.id] = true && item.push(next);
						// 	return item;
						// }, []);
						// console.log(this.msgs, '信聊天记录999---')

						// 调用回到底部方法
						if (newData.length > 0) {
							setTimeout(() => {
								this.initScrollBar();
								// this.scrollToBottom();
							}, 100);
						}
					})
					.catch((err) => {
						clearTimeout(this.timer); //清理定时任务
						// uni.hideLoading();
						uni.stopPullDownRefresh();
						_this.$util.Tips({
							title: err,
						});
					});
			},
			// 去重的方法
			ArrSet(Arr, id) {
				// console.log(Arr,id,'去重接收的参数999')
				var obj = {};
				const arrays = Arr.reduce((setArr, item) => {
					if (item.id) {
						// 接口获取的有id
						obj[item[id]] ? "" : (obj[item[id]] = true && setArr.push(item));
					} else {
						// 自己发送的没有id 需要把发送的信息push到数组中
						setArr.push(item);
					}
					return setArr;
				}, []);
				return arrays;
			},
			// 点击去购药
			gotoBuyDrug(id, orderType) {
				// orderType有可能为空
				uni.navigateTo({
					url: `/pages/my/toBuyMedicine?id=${id}&orderType=${orderType}&storeType=1`,
				});
			},

			// 滑到底部
			// scrollToBottom() {
			// 	let that = this;
			// 	let query = uni.createSelectorQuery();
			// 	query.selectAll(".msg-item").boundingClientRect();
			// 	query.select("#scroll-view").boundingClientRect();
			// 	// console.log('到底不方法执行了没999---', query)
			// 	query.exec((res) => {
			// 		that.style.mitemHeight = 0;
			// 		res[0].forEach(
			// 			(rect) =>
			// 			(that.style.mitemHeight = that.style.mitemHeight + rect.height + 40)
			// 		); //获取所有内部子元素的高度
			// 		// console.log(res, 'res9999----', this.style, '999---')
			// 		setTimeout(() => {
			// 			if (that.style.mitemHeight > that.style.contentViewHeight - 100) {
			// 				//判断子元素高度是否大于显示高度
			// 				// console.log(that.style, '条件成立999--')
			// 				that.scrollTop =
			// 					that.style.mitemHeight - that.style
			// 					.contentViewHeight; //用子元素的高度减去显示的高度就获益获得序言滚动的高度
			// 				// console.log(that.scrollTop, that.style.mitemHeight, that.style
			// 				// 	.contentViewHeight, '网上滚动高度9999---')
			// 			}
			// 		}, 100);
			// 	});
			// },
			// 获取会话信息--剩余回合数
			getChatInfo() {
				// uni.showLoading({
				// 	title: '加载中'
				// });
				getSessionInfo(this.doctorId, this.patientId)
					.then((res) => {
						if (res.data) {
							this.isActivation = res.data.isActivation;
							if (res.data.isActivation == 1) {
								// 未激活
								this.hideEnd = false; //结束问诊按钮
								this.hideHasNum = false; //回合数文案
								this.hasEndTime = false;
								// 未激活时底部页面滚动区域增大
								const res = uni.getSystemInfoSync(); //获取手机可使用窗口高度     api为获取系统信息同步接口
								// console.log(res, '手机高度999')
								this.style.pageHeight = res.windowHeight;
								this.style.contentViewHeight =
									res.windowHeight - (res.screenWidth / 750) * 100 -
									40; //像素   因为给出的是像素高度 然后我们用的是upx  所以换算一下
								if (this.platform == "ios" || this.platform == "devtools") {
									this.style.contentViewHeight =
										res.windowHeight - (res.screenWidth / 750) * 100 -
										70; //像素   因为给出的是像素高度 然后我们用的是upx  所以换算一下
								}
								// console.log(this.style, this.style.contentViewHeight, 'hhhh999999---')
							} else {
								// 激活后
								this.hideEnd = true;
								// 未激活时底部页面滚动区域增大
								const app = uni.getSystemInfoSync(); //获取手机可使用窗口高度     api为获取系统信息同步接口
								this.style.pageHeight = app.windowHeight;
								this.style.contentViewHeight =
									app.windowHeight - (app.screenWidth / 750) * 100 -
									110; //像素   因为给出的是像素高度 然后我们用的是upx  所以换算一下
								// 适配ios系统
								if (app.platform == "ios" || this.platform == "devtools") {
									this.style.contentViewHeight =
										app.windowHeight - (app.screenWidth / 750) * 100 - 140; //像素   因为给出的是像素高度 然后我们用的是upx  所以换算一下
								}
							// console.log(this.style.contentViewHeight,' 激活后高度')
							if (this.queryParams.pageNum < 2) {
									this.scrollToBottom(); //滑到底部
								}
								// console.log(res.data,999999)
								if (res.data.orderType) {
									if (res.data.orderType == 1) {
										// 订单类型==1 图文问诊 不限制次数，展示倒计时
										this.hideHasNum = false;
										// 显示倒计时 并给结束时间赋值
										this.hasEndTime = true;
										this.endTime = res.data.endTime || "";
									} else {
										this.hideHasNum = true;
										this.hasNum = res.data.count || "0"; //回合次数
										// 不显示倒计时
										this.hasEndTime = false;
									}
								} else {
									this.hideHasNum = true;
									this.hideEnd = false;
									this.hasNum = res.data.count || 0; //回合次数
								}
							}
						} else {
							// 未激活
							this.hasEndTime = false;
							this.hideHasNum = false;
							this.hasNum = res.data == null ? 0 : res.data.count; //回合次数
							this.hideEnd = false;
						}
						// uni.hideLoading();
					})
					.catch((err) => {
						console.log(err, "会话信息err");
						// uni.hideLoading();
					});
			},

			// //关闭处方
			closeCf() {
				this.$refs.medApplyPopup.close()
			},
			// 更新已读状态
			postUpdateReadStatus() {
				uni.showLoading({
					title: "加载中",
				});
				updateReadStatus({
						patientId: this.patientId,
						doctorId: this.doctorId,
					})
					.then((res) => {
						uni.hideLoading();
					})
					.catch((err) => {
						console.log(err, "更新已读状态err");
						uni.hideLoading();
						return this.$util.Tips({
							title: err,
						});
					});
			},

			// 进入页面获取第一页的会话消息
			async getRecordList(obj) {
				let _this = this;
				let newData = [];
				let listData = _this.listData;
				let nowCount = _this.nowCount;
				let pageNum = _this.queryParams.pageNum;
				if (obj) {
					_this.msgs = [];
					_this.queryParams.pageNum = obj.pageNum;
					pageNum = _this.queryParams.pageNum;
				}
				// uni.showLoading({
				// 	title: '加载中'
				// });

				console.log(_this.doctorId, _this.patientId, _this.queryParams,'请求参数999---')
				// return
				await recordList(_this.doctorId, _this.patientId, _this.queryParams)
					.then((res) => {
						if (res.code == 200) {
							// 获取会话激活状态及剩余回合数
								this.getChatInfo();  //请求激活状态
							if (pageNum > 1) {
								newData = res.rows.reverse().concat(_this.msgs);
								// console.log('超过1页')
							} else {
								// console.log('第一页')
								newData = _this.msgs.concat(res.rows.reverse());
							}
							if (newData.length === res.total) {
								this.allHistoryLoaded = true;
							}
							// this.showLoadMore = true;
							this.sessionId = newData[0].sessionId || 0;
							newData.map((item) => {
								if (typeof item.chatContent != "object") {
									if (
										item.sendType == 1 ||
										item.sendType == 8 ||
										item.sendType == 2 ||
										item.sendType == 4 ||
										item.sendType == 7
									) {
										// 1--,现场开方消息 2.图文咨询消息 3 图片 4. 语音 5. 普通消息 6 提醒消息 7. 用药咨询 8 开具处方 9. 问诊小结
										if (item.chatContent) {
											item.chatContent = JSON.parse(item.chatContent);
										}
										return item;
									}
									return item;
								}
							});
							_this.$set(_this, "msgs", newData);
							_this.total = res.total;
							_this.queryParams.pageNum = pageNum + 1;
							_this.nowCount = nowCount + res.rows.length;

							// console.log(this.nowCount, this.total,999998888)
							if (res.total < 1) {
								this.showLoadMore = false;
							}
							// uni.hideLoading();
							uni.stopPullDownRefresh();
							//调用回到底部方法
							// if (pageNum < 2) {
								// console.log(111, 999, '999----')
								setTimeout(() => {
									// this.scrollToBottom();
									this.initScrollBar();
								}, 500);
							// }
						} else {
							uni.showToast({
								title: res.msg,
								icon: "none",
								duration: 3000,
							});
						}
						// uni.hideLoading();
					})
					.catch((err) => {
						uni.stopPullDownRefresh();
						// uni.hideLoading();
						uni.showToast({
							title: err,
							icon: "none",
							duration: 3000,
						});
					});
			},

			// 图片预览
			imgView(index, item) {
				uni.previewImage({
					current: index,
					urls: item,
				});
			},
		
			// // 去查看电图文问诊详情
			toSeePicDetail(id, orderId) {
				// if (id && orderId) {
				let url = `/pagesSub-My/my/inquiryDetails?consultId=${id}&orderId=${orderId}`
				uni.navigateTo({
					url: url
				})
			},

			// // 去查看电子处方
			toSeePrescription(url) {
				// console.log(url, '点击跳转的url8888----')
				uni.navigateTo({
					url: url
				})
			},
			// 点击用药申请弹窗
			toSeeMedApply(chatContent) {
				this.chatContent = chatContent; //存一下聊天页面中该项信息的内容
				let _this = this;
				_this.$refs.medApplyPopup.open('center');
				uni.showLoading({
					title: '加载中'
				});
				patientDetail(chatContent.id)
					.then(res => {
						_this.prescriptionInfo = res.data;
						uni.hideLoading();
					})
					.catch(res => {
						uni.hideLoading();
					});
			},

			// 发送
			sendTextMessage(params) {
				if (this.hideHasNum && this.hasNum < 1) {
					return uni.showToast({
						title: "回合数耗尽，无法发送消息",
						icon: "none",
						duration: 3000,
					});
				}
				if (!this.msgText) {
					uni.showToast({
						title: "请输入信息",
						icon: "none",
					});
					return;
				}
				let msgObj = {
					chatContent: this.msgText,
					sendType: 5,
					fromUser: this.patientId,
					toUser: this.doctorId,
				};

				// this.more.show = !this.more.show; //
				this.sendMessageApi(msgObj);
			},

			// 图片
			gotoCamera() {
				if (this.hideHasNum && this.hasNum < 1) {
					uni.showToast({
						title: "回合数耗尽，无法发送消息",
						icon: "none",
						duration: 3000,
					});
				} else {
					uni.chooseImage({
						count: 1,
						sizeType: ["compressed"],
						sourceType: ["album", "camera"],
						success: (res) => {
							this.imgUpload(res.tempFilePaths);
						},
						fail: (err) => {},
					});
				}
			},
			// 上传语音
			videoUpload(tempFilePath, contentDuration) {
				let _this = this;
				let uploadVideo = [];
				uploadVideo.push(
					new Promise((resolve, reject) => {
						uni.uploadFile({
							url: HTTP_REQUEST_URL + "wx/common/savePatientPicInfo",
							filePath: tempFilePath,
							fileType: "video",
							name: "fileName",
							header: {
								[TOKENNAME]: store.state.app.token,
								uid: store.state.app.uid,
							},
							success: (res) => {
								// uni.hideLoading();
								_this.$util.Prom(res.code, res.msg);
								resolve(res);
								var _res = JSON.parse(res.data);
								if (_res.code == 200) {
									let msgObj = {
										chatContent: JSON.stringify({
											audioTime: Math.ceil(
											contentDuration), //this.audioTime,
											audioUrl: _res.data.url,
										}),
										sendType: 4,
										fromUser: this.patientId,
										toUser: this.doctorId,
									};
									// 调用发送接口
									this.sendMessageApi(msgObj);
								}
							},
							fail: (err) => {
								// uni.hideLoading();
								console.log(err);
								reject(err);
							},
							complete: () => {},
						});
					})
				);
				Promise.all(uploadVideo) //执行所有需请求的接口
					.then((results) => {
						uni.hideLoading();
					})
					.catch((res, object) => {
						uni.hideLoading();
					});
			},

			imgUpload(tempFilePaths) {
				let _this = this;
				// uni.showLoading({
				// 	title: '上传中'
				// });
				let uploadImgs = [];
				tempFilePaths.forEach((item, index) => {
					uploadImgs.push(
						new Promise((resolve, reject) => {
							// console.log(index, item)
							uni.uploadFile({
								url: HTTP_REQUEST_URL + "wx/common/savePatientPicInfo",
								filePath: item,
								fileType: "image",
								name: "fileName",
								header: {
									[TOKENNAME]: store.state.app.token,
									uid: store.state.app.uid,
								},
								success: (res) => {
									// uni.hideLoading();
									_this.$util.Prom(res.code, res.msg);
									// console.log('uploadFileRes', res)
									resolve(res);
									var _res = JSON.parse(res.data);
									if (_res.code == 200) {
										this.image = _res.data.url;
										let msgObj = {
											chatContent: this.image,
											sendType: 3,
											toUser: this.doctorId, //store.state.app.uid,
											fromUser: this.patientId,
										};
										// console.log(msgObj, '发送图片的参数999---');
										// 调用发送接口
										this.sendMessageApi(msgObj);
									}
								},
								fail: (err) => {
									// uni.hideLoading();
									console.log(err);
									reject(err);
								},
								complete: () => {
									//uni.hideLoading();
								},
							});
						})
					);
				});
				Promise.all(uploadImgs) //执行所有需请求的接口
					.then((results) => {
						uni.hideLoading();
					})
					.catch((res, object) => {
						uni.hideLoading();
					});
			},

			// 发送消息调用的接口
			sendMessageApi(msgObj) {
				chatSend(msgObj, {})
					.then((res) => {
						if (res.code == 200) {
							// 获取聊天消息
							if (msgObj.sendType == 4) {
								// 语音消息
								msgObj.chatContent = JSON.parse(msgObj.chatContent);
							} else if (msgObj.sendType == 5) {
								// 普通消息
								this.msgText = "";
							}
							this.msgs.push(msgObj);
							this.hasNum = res.data.count; //剩余回合数
							//调用回到底部方法
							setTimeout(() => {
								this.initScrollBar();
								// this.scrollToBottom();
							}, 500);
							this.$set(this, "msgs", this.msgs);
						} else {
							uni.showToast({
								title: res.msg,
								icon: "none",
								duration: 3000,
							});
						}
					})
					.catch((err) => {
						console.log(err, "发送消息err");
						uni.showToast({
							title: err,
							icon: "none",
						});
					});
			},
			showImageFullScreen(e) {
				var imagesUrl = [e.currentTarget.dataset.url];
				uni.previewImage({
					urls: imagesUrl,
				});
			},
			// 发送&+
			showSendImg() {
				this.showOptions = !this.showOptions;
			},

			// 点击语音/键盘
			clickVoice() {
				let _this = this;
				// _this.isVoice = !(_this.isVoice);
				// // 获取录音权限是否开启
				uni.authorize({
					scope: "scope.record",
					success() {
						// 有权限，，改成键盘
						_this.isVoice = !_this.isVoice;
					},
					fail() {
						_this.isVoice = true;
						_this.isDisabledButton = true;
						uni.showToast({
							title: "录音权限获取失败，无法发送语音。",
							icon: "none",
							duration: 3000,
						});
					},
					complete() {
						// console.log(_this.isVoice, 'isvoice9999---')
					},
				});
			},

			// 点击输入框
			clickInput() {
				// console.log('点击输入框')
			},

			// 退诊弹框
			openRefusal(id) {
				this.WithdrawalId = id;
				this.$refs.refusalPopup.open('center')
			},
			// // 点击退诊弹窗的取消按钮
			dialogClose() {
				this.$refs.refusalPopup.close();
			},
			// 确定退诊
			refusalConfirm() {
				this.disabledSave = true;
				uni.showLoading({
					title: '加载中'
				});
				Withdrawal({
						id: this.WithdrawalId
					})
					.then(res => {
						this.disabledSave = false;
						// 退诊成功后，按钮展示已退诊，
						this.getRecordList({
							pageNum: 1
						}); //获取聊天信息
						uni.hideLoading();
						this.$util.Prom(res.code, res.msg);
						this.$refs.refusalPopup.close();
					})
					.catch(err => {
						this.disabledSave = false;
						uni.hideLoading();
						uni.showToast({
							title: err,
							icon: 'none',
							duration: 3000
						});
						console.log(err, 'err拒诊');
					});
			}
		},
	};
</script>

<style scoped lang="scss">
	@import "@/static/css/chatInterface.css";


.container{
	height: 100vh;
	overflow: hidden;

}
.scroll{
	margin-top:140rpx;
	overflow-y: auto;
	transition: all 1s ease;
	height: calc(100vh - 78upx - var(--status-bar-height));
	
	/* #ifdef MP-WEIXIN */
	height: calc(100vh - 88upx - var(--status-bar-height));
	/* #endif */
	/* #ifdef H5 */
	height: calc(100vh - 88upx - 110upx - var(--status-bar-height));
	/* #endif */

	#bottom{
		height:0
	}
}
	.avatar {
		width: 120rpx;
		height: 120rpx;
		border: 1px solid blue;
	}

	.all-history-loaded {
		font-size: 24rpx;
		height: 90rpx;
		line-height: 90rpx;
		width: 100%;
		text-align: center;
		color: grey;
	}

	/* 语音 */
	.record-input {
		/* width: 460rpx; */
		width: calc(100% - 260rpx);
		height: 60rpx;
		line-height: 60rpx;
		border-radius: 12rpx;
		font-size: 14px;
		background: #cccccc;
		color: #ffffff;
		text-align: center;
	}

	.record-loading {
		position: fixed;
		top: 50%;
		left: 50%;
		width: 300rpx;
		height: 300rpx;
		margin: -150rpx -150rpx;
		background: #262628;
		background: url("@/pagesSub/static/images/recording-loading.gif") no-repeat center;
		background-size: 100%;
		border-radius: 40rpx;
		z-index: 999999;
	}

	.navBar {
		position: fixed;
		/* top: 50rpx; */
		z-index: 99999;
		width: 100%;
	}

	.main-wrap {
		/* position: relative; */
		height: 100%;
		min-height: 100%;
		display: flex;
		flex-direction: column;
		background-color: #eeeeee;
	}

	/* 高度等于容器高度减去tags-wrap、input-wrap 高度，如果高度改变，值需要调整 */
	.msg-wrap {
		padding: 15rpx 20rpx;
		// overflow-y: auto;
		min-height: 800rpx;
		/* height: calc(100% - 216rpx); */
		max-height: 1000rpx;
	}

	.msg-item {
		margin-bottom: 40rpx;
	}

	.msg-con-wrap {
		display: flex;
		margin-bottom: 10rpx;
	}

	.msg-left {
		justify-content: flex-start;
		font-size: 29rpx;
	}

	.chufang {
		font-size: 29rpx;
		text-align: center;
		padding: 10rpx;
		line-height: 40rpx;
		height: 40rpx;
	}

	.patientInfo {
		font-size: 29rpx;
		width: 100%;
		line-height: 40rpx;
		padding: 5px 0;
	}

	.msg {
		padding: 0 10rpx;
		// line-height: 30px;
		max-width: 70%;
		overflow: hidden;
		/* // calc(100% - 120rpx); */
		border-radius: 12rpx;
		background-color: #fff;
	}

	.msgImage {
		background-color: transparent;
	}

	.msg-left .msg {
		margin-left: 20rpx;
		// line-height: 80rpx;
	}

	.msg-left .left-txt-msg {
		background-color: #ffffff;
		color: #000000;
		padding: 10px;
		word-wrap: break-word;
		// line-height: 44rpx;
		// height: 80rpx;
	}

	/* 语音 和普通消息 */
	.right-txt-msg {
		background-color: #50c9bd;
		color: #ffffff;
		padding: 10px;
		word-wrap: break-word;
		// line-height: 44rpx;
		// height: 80rpx;
	}

	/* 右侧消息 */
	.msg-right {
		justify-content: flex-end;
		font-size: 14px;
	}

	.chufangMsg {
		padding: 0 10rpx;
		width: 70%;
		overflow: hidden;
	}

	.msg-right .msg {
		margin-right: 20rpx;
		// line-height: 60rpx;
	}

	.msg-right .chufangMsg {
		margin-right: 20rpx;
	}

	.EWM {
		margin-top: 20rpx;
		background-color: #ffffff;
	}

	// .right-msg {
	// 	background: #50C9BD;
	// 	color: #FFFFFF;
	// }

	.toSeeBtn {
		margin: 16rpx auto;
		width: 100px;
		display: flex;
		justify-content: center;
		background-color: #4cccbf;
		border-radius: 40rpx;
		color: #ffffff;
		font-size: 14px;
	}

	.avatar-wrap {
		display: inline-block;
		width: 80rpx;
		height: 80rpx;
		border-radius: 100%;
		border: 1rpx solid #ddd;
	}

	.time-wrap {
		display: block;
		width: 100%;
		text-align: center;
		color: gray;
		font-size: 29rpx;
		margin-bottom: 10rpx;
	}

	.footer {
		background-color: #ddd;
	}

	/* 剩余回合数 */
	.num-text-wrap {
		text-align: center;
		font-size: 29rpx;
		line-height: 40rpx;
		padding-top: 6rpx;
		// background-color: #FAFAFA;
	}

	/* tags多功能按钮 */
	.tags-wrap {
		display: flex;
		padding: 4rpx 10rpx;
		justify-content: flex-start;
	}

	.tags-btn {
		background-color: #fff;
		margin-right: 10rpx;
		border: 1px solid #eee;
		height: 50rpx;
		padding: 0 16rpx;
	}

	/* 底部footer */
	.input-wrap {
		display: flex;
		padding: 15rpx 10rpx;
		align-items: center;
		justify-content: space-between;
	}

	/* input 宽度等于容器100% 宽度减去两边按钮宽度 */
	.input {
		width: calc(100% - 260rpx);
		padding: 10rpx;
		background-color: #fff;
	}

	.input-btn {
		margin: 0;
	}

	.play {
		width: 60rpx;
		height: 60rpx;
	}

	.bottom-wrap {
		display: flex;
		background-color: #eeeeee;
		padding: 20rpx 10rpx;
	}

	.option {
		display: inline-block;
		width: 150rpx;
		height: 150rpx;
		border-radius: 16rpx;
		background-color: #ddd;
		text-align: center;
		line-height: 150rpx;
		margin: 0 10rpx;
	}

	/* 开具处方 */
	.text-wrap {
		margin: 4rpx;
	}

	.drugNameRow {
		background-color: #f6fafa;
		word-break: break-all;
	}

	/* 卡片 */
	/deep/ .uni-card[data-v-19622063] {
		margin: 0;
	}

	/deep/ .uni-card__title[data-v-19622063] {
		background-color: #aaaaaa;
	}

	.footer-box {
		// margin-top: 40rpx;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		justify-content: space-around;
		flex-direction: row;
	}

	.chatBtn {
		width: 40%;
		font-size: 14px;
		height: 60rpx;
		margin: 10rpx auto;
		line-height: 60rpx;
		background-color: #fff;
		color: #ffffff;
		background-color: #50c9bd;
		border-radius: 60rpx;
		// border: 1px solid #50C9BD;
	}

	.receiveBtn {
		border: 1px solid #18b566;
		color: #18b566;
	}

	/* 图片类型*/
	.imageMsg {
		width: 300rpx;
		height: 300rpx;
		// background-position: center;
		// background-repeat: no-repeat;
		// background-size: 100%;
	}

	.image-box {
		/* #ifndef APP-NVUE */
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
		/* #endif */
		/* height: 350rpx; */
		// overflow: hidden;
	}

	.image {
		width: 80rpx;
		height: 80rpx;
		margin-right: 10rpx;
	}

	.dialogContent {
		width: 550rpx;
		padding: 30rpx;
		border-radius: 10rpx;
		background-color: #ffffff;
	}

	.drugTit {
		display: flex;
		justify-content: space-between;
		font-size: 14px;
	}

	.content {
		border-top: 8rpx solid #acacac;
		margin: 20rpx auto;
		font-size: 14px;
		line-height: 76rpx;
		border-bottom: 1px solid #f0f0f1;
	}

	.content view {
		display: flex;
		justify-content: space-between;
	}

	.scroll-Y {
		max-height: 400rpx;
	}

	.prompt {
		margin: 15rpx 0;
		padding: 10rpx 15rpx;
		background-color: #f6f6f6;
		font-size: 14px;
		color: #9c9b9b;
		border-radius: 14rpx;
	}

	.RP_content {
		border: 1px solid #f4f4f6;
		padding: 10rpx;
		margin: 10rpx 0;
		font-size: 12px;
	}

	// .rp_title {
	// 	line-height: 54rpx;
	// }

	// .rp_text {
	// 	font-size: 22rpx;
	// }

	// .btn_pro {
	// 	background-color: #6da3ff;
	// 	color: #ffffff;
	// }

	.picWordTips {
		margin: 5px auto;
		text-align: center;
		color: #50c9bd;
		border-radius: 40rpx;
		width: 200rpx;
		line-height: 60rpx;
	}

	.aduitStatus {
		background-color: #d0f4ed;
		color: #81d7c5;
		font-size: 12px;
		padding: 0 3px;
	}

	/* 弹出框 */
	.inputDialog {
		width: 600rpx;
		border-radius: 10rpx;
		background-color: #ffffff;
	}

	/deep/.input-padding[data-v-abe12412] {
		padding: 20rpx !important;
	}

	.inputvalue {
		background-color: #f6f6f6;
	}

	.inputDialog>.title {
		text-align: center;
		padding: 20rpx;
		font-size: 30rpx;
	}

	.button-bottom {
		display: flex;
		border-top: 1px solid #f0f0f0;
	}

	.button-bottom view {
		width: 50%;
		padding: 20rpx 0 20rpx 0;
		font-size: 30rpx;
		text-align: center;
	}

	// .rejectStatus {
	// 	background-color: #D57667;
	// 	color: #FFFFFF;
	// 	font-size: 12px;
	// 	padding: 0 3px;
	// }
</style>
